

package com.base.test.mutual.redis;
import com.base.commons.tools.redis.RedisUtils;
import com.base.test.mutual.utils.RedisKeys;
import com.base.test.mutual.dto.BscJwtToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 验证码Redis
 * @author  carl
 * @since 1.0.0
 */
@Component
public class BscTokenRedis {
    /**  过期时长为3小时，单位：秒 */
    public final static long HOUR_ONE_EXPIRE = 60 * 60 * 3L;
    @Autowired
    private RedisUtils redisUtils;

    public void set(BscJwtToken token, String name){
      String key= RedisKeys.getBscTokenKey(name);
        redisUtils.set(key, token, HOUR_ONE_EXPIRE);
    }

    public BscJwtToken get(String name){
        String key= RedisKeys.getBscTokenKey(name);
        return (BscJwtToken) redisUtils.get(key);
    }

}